<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
	<title>室内使用情况</title>
    <base href="<%=basePath%>"> 
    <meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<link rel="stylesheet" href="css/bootstrap.css">
	<link rel="stylesheet" href="css/common.css">
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<script src="js/jquery-1.11.1.js"></script>
    <script type="text/javascript" src="js/layer/layer/layer.js"></script> 
    <link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
	<script src="js/select2/select2.min.js"></script>
	<script type="text/javascript">
		
	$(document).ready(function() {
		var s1=$("#storage").select2({minimumResultsForSearch: Infinity});
		var s2=$("#roomType").select2({minimumResultsForSearch: Infinity});
		var s3=$("#workInfo").select2({minimumResultsForSearch: Infinity});
		initSelectData();
		initSelectData2();
		initSelectData3();
		var roomType = '${record.roomType}';
		var storage = '${record.storage}';
		var workInfo = '${record.workInfo}';
		s1.val(storage).trigger("change");
		s2.val(roomType).trigger("change");
		s3.val(workInfo).trigger("change");
	});
	
	function initSelectData(){
		var html = "";
		var arr = ["起居室","餐厅","厨房","储物间","卫生间","房间","平台","阳台"];
		for(var i = 0;i<arr.length;i++){
			html = "<option value=\""+arr[i]+"\">"+arr[i]+"</option>";
			$("#roomType").append(html);
		}
	}
	
	function initSelectData2(){
		var html = "";
		var arr = ["危险品","非危险品","其他"];
		for(var i = 0;i<arr.length;i++){
			html = "<option value=\""+arr[i]+"\">"+arr[i]+"</option>";
			$("#storage").append(html);
		}
	}
	
	function initSelectData3(){
		var html = "";
		var arr = ["办公","会议","餐厅","其他"];
		for(var i = 0;i<arr.length;i++){
			html = "<option value=\""+arr[i]+"\">"+arr[i]+"</option>";
			$("#workInfo").append(html);
		}
	}
	
	function change(obj){
		var val = $(obj).val();
		if(val=="餐厅"){
			$("#panel_5").hide();
		}else if(val=="厨房" || val=="储物间" || val=="卫生间" || val=="平台" || val=="阳台"){
			$("#panel_1").hide();
			$("#panel_11").hide();
			$("#panel_2").hide();
			$("#panel_3").hide();
			$("#panel_5").hide();
		}
	}
	
	function saveDocument(){
		var roomInfoId=$("#roomInfoId").val();
		var customerId=$("#customerId").val();
		var peopleCount=$("#peopleCount").val();
		var resident=$("resident").val();
		var storage=$("#storage").val();
		var workInfo=$("#workInfo").val();
		var tradeFair=$("#tradeFair").val();
		var other=$("#other").val();
		var roomStatus=$("#roomStatus").val();
		var roomType=$("#roomType").val();
		var AccessoryCaList=$("#AccessoryCaList").val();
		var url="project/decorateManager/editIndoor";
		$.ajax({
		    type:"post",
		    async:false,
		    url:url,
	        dataType:"json",
	        data:{
	        	roomId:roomInfoId,
	        	customerId:customerId,
	        	peopleCount:peopleCount,
	        	resident:resident,
	        	storage:storage,
	        	workInfo:workInfo,
	        	tradeFair:tradeFair,
	        	other:other,
	        	roomStatus:roomStatus,
	        	roomType:roomType,
	        	AccessoryCaList:AccessoryCaList
	        },
		    success:function(responseText){
		        if(responseText.success){
		        	alert(responseText.msg, {icon: 7});
		        	closeIframe();
    			}else{
    				alert(responseText.msg, {icon: 7});
    			}
		    }
   		});
	}
		
	</script>
	<style type="text/css">
	.td_l {
		width: 80px;
	}
	tr{
		height:40px;
		margin:10px;
	}
	
	</style>
	</head>
	<body>
		<form class="cmxform" id="commentForm" method="get" action="">
		<div style="padding:10px 20px">
		
		<div class="panel panel-default">
			<div class="panel-heading">
      				<h5 class="panel-title">室内使用信息</h5>
   			  	</div>
   			<div class="panel-body">
			<table >
				<tr id="panel2">
					<td>房间类型</td>
					<td>
						<select  class="js-example-basic-single" name="roomType" id="roomType" style="width:135px;" onchange="change(this)">
						</select>
					</td>
					<td width="90" id="panel_1">客户</td>
					<td id="panel_11">
						<input type="text" id="customerName" name="customerName" value="${record.fkcustomerId.customerName }"/>&nbsp;&nbsp;
						<input type="hidden" id="customerId" name="customerId" value="${record.fkcustomerId.id }"/>
						<!-- <a class="btn btn-primary radius" onClick="doSearch(this)">选择</a>  -->
					</td>
				</tr>
				<tr id="panel_2">
					<td width="90">居住人数</td>
					<td >
						<input type="text" id="peopleCount" name="peopleCount" value="${record.peopleCount }"/>
					</td>
					<td width="90">居住人</td>
					<td >
						<input type="text" id="resident" name="resident" value="${record.resident }"/>
					</td>
				</tr>
				<tr id="panel_3">
					<td width="90">商展</td>
					<td>
						<input type="text" name="tradeFair" id="tradeFair" value="${record.tradeFair }"/> 
					</td>
					<td width="90" >办公</td>
					<td>
						<select class="js-example-basic-single" name="workInfo" id="workInfo"  style="width:90px;">
							
						</select>
					</td>
				</tr>
				<tr id="panel_4">
					<td width="90">仓储</td>
					<td>
						<select class="js-example-basic-single" name="storage" id="storage"  style="width:90px;">
							
						</select>
					</td>
					<td width="90">其他</td>
					<td>
						<input type="text" name="other" id="other" value="${record.other }"/> 
					</td>
				</tr>
				<tr id="panel_5">
					<td colspan="4" >
						<!-- 附件上传 -->
						<%@include file="../../p_utilePage/Article.jsp" %>
					</td>
				</tr>
			</table>
			</div>
			</div>
			<div style="width:100%;text-align:center; padding-top:20px"> 
				<button class="btn btn-primary radius" onclick="saveDocument()" > 保 存</button> 
				 <a class="btn btn-default radius" onclick="javascript:window.history.go(-1)"> 取 消 </a> 
		    	  <br/><br/>
	    	</div> 
		</div>
		<input type="hidden"  id="roomInfoId" name="roomInfoId" value="${record.fkroomId.id }"/>
		<input type="hidden"  id="roomStatus" name="roomStatus" value="${record.roomStatus }"/><!-- 0空置 1 再用 -->
		</form>
  	</body>
  	
   </html>
